#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--)
    {
        int h,a,H,A;
        cin>>h>>a>>H>>A;

        int g=ceil(double(H)/a);
        if(g==1)
        {
            cout<<-1<<endl;
            continue;
        }
        int s=(g-1)*A;
        int ret=(h-1)/s;
        cout<<ret<<endl;

    }
    return 0;
}
